package com.ruyuan.eshop.market.dao;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruyuan.eshop.common.dao.BaseDAO;
import com.ruyuan.eshop.market.domain.entity.CouponDO;
import com.ruyuan.eshop.market.mapper.CouponMapper;
import org.springframework.stereotype.Repository;

/**
 <p>
 优惠券领取记录管理DAO组件
 </p>
 * 儒猿课堂: http://www.ruyuan2020.com
 * @Author zhonghuashishan
 * @Remark 有问题直接联系客服VX: ruyuan-1111 ，源码-笔记-技术交流群
 * @Version 1.0
 **/
@Repository
public class CouponDAO extends BaseDAO<CouponMapper, CouponDO> {

    /**
     * 查询优惠券
     *
     * @param userId
     * @param couponId
     * @return
     */
    public CouponDO getUserCoupon(String userId, String couponId) {
        QueryWrapper<CouponDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId)
                .eq("coupon_id", couponId);
        return getOne(queryWrapper);
    }
}
